package cn.edu.zafu.bigdata.lhff;

import java.util.Scanner;

public class ScoreValidationExample {

    public static class InvalidScoreException extends Exception {
        public InvalidScoreException(String message) {
            super(message);
        }
    }

    public static void checkScore(int score) throws InvalidScoreException {
        if (score < 0 || score > 100) {
            throw new InvalidScoreException("错误：分数必须在0到100之间");
        } else {
            System.out.println("分数有效：" + score);
        }
    }

    public static void main(String[] args) {
        try (Scanner scanner = new Scanner(System.in)) {
            System.out.print("请输入分数：");

            int score = scanner.nextInt();
            checkScore(score);
        } catch (InvalidScoreException e) {
            System.out.println(e.getMessage());
        } catch (Exception e) {
            System.out.println("无效的输入，请输入一个整数。");
        }
    }
}
